Page({
  data: {
    latitude: 23.099994,
    longitude: 113.324520,
    markers: [],
    circles: [],
    me: {},
    job: {},
  },
  onLoad: function (e) {

    try {
      var value = wx.getStorageSync('lc')
      if (value) {
        let {
          me,
          job
        } = JSON.parse(value);

        this.setData({
          me,
          job,
          latitude: job.lat,
          longitude: job.lng,
          circles: [{
            latitude: job.lat,
            longitude: job.lng,
            color: "#10C15766",
            fillColor: "#10C15766",
            radius: 2000
          }],
          markers: [{
              id: 1,
              latitude: job.lat,
              longitude: job.lng,
              iconPath: "/public/image/l-q.png",
              width: 34,
              height: 40,
            },
            {
              id: 2,
              latitude: me.lat,
              longitude: me.lng,
              iconPath: "/public/image/l-m.png",
              width: 34,
              height: 40,
            },
          ],
        })
        // Do something with return value
      }
    } catch (e) {
      // Do something when catch error
    }



  },
  onReady: function (e) {
    this.mapCtx = wx.createMapContext('myMap')
  },
  getCenterLocation: function () {

    console.log("----设置中点----", this.data.job)
    this.mapCtx.moveToLocation({
      latitude:this.data.job.lat,
      longitude:this.data.job.lng,
    })
    // this.setData({
    //   latitude:34.791604,// Number( ),
    //   longitude:113.544163//Number( ),
    // })
    // this.mapCtx.getCenterLocation({
    //   success: function (res) {
    //     console.log(res.longitude)
    //     console.log(res.latitude)
    //   }
    // })
  },
  onclickBack: function () {
    wx.navigateBack({
      delta: 1,
    })
  },
  moveToLocation: function () {

    this.mapCtx.moveToLocation()
  },
  translateMarker: function () {
    this.mapCtx.translateMarker({
      markerId: 1,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude: 23.10229,
        longitude: 113.3345211,
      },
      animationEnd() {
        console.log('animation end')
      }
    })
  },
  includePoints: function () {
    this.mapCtx.includePoints({
      padding: [10],
      points: [{
        latitude: 23.10229,
        longitude: 113.3345211,
      }, {
        latitude: 23.00229,
        longitude: 113.3345211,
      }]
    })
  }
})